package com.highcom.product.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.highcom.product.entity.DetailsEntity;
import com.highcom.product.service.DetailsService;
import com.highcom.common.utils.PageUtils;
import com.highcom.common.utils.R;



/**
 * 
 *
 * @author maboxuan
 * @email sunlightcs@gmail.com
 * @date 2023-09-28 16:42:54
 */
@RestController
@RequestMapping("product/details")
public class DetailsController {
    @Autowired
    private DetailsService detailsService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = detailsService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{pictures}")
    public R info(@PathVariable("pictures") String pictures){
		DetailsEntity details = detailsService.getById(pictures);

        return R.ok().put("details", details);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody DetailsEntity details){
		detailsService.save(details);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody DetailsEntity details){
		detailsService.updateById(details);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody String[] picturess){
		detailsService.removeByIds(Arrays.asList(picturess));

        return R.ok();
    }

}
